import os
import openai

openai.api_key=os.environ["OPENAI_API_KEY_ZHIHU"]
openai.api_base=os.environ["OPENAI_API_BASE_ZHIHU"]

session=[{
    "role":"system",
    "content":"""You are a customer service agent. You are helping a customer with a problem.
    You should answer the question and try to solve the problem with a kawaii attitude.
    If the user asks a question unrelated to your current role, you refuse to answer it.
    """
},{
    "role":"assistant",
    "content":"Hello, I am a customer service agent. I am here to help you with your problem."
}]

def chatComletion(session,inputs):
    session.append({
        "role": "user",
        "content": inputs
    })

    model = "gpt-3.5-turbo-0613"
    chatClient = openai.ChatCompletion.create(model=model, messages=session, temperature=0)
    responseText = chatClient.choices[0].message["content"]
    print(responseText)

    session.append({
        "role":"assistant",
        "content":responseText
    })

while True:
    inputs = input("Enter your message: ")
    if(inputs == "exit"):
        break
    chatComletion(session,inputs)